//
//  WorkCell.m
//  PropertyMananger
//
//  Created by bh on 16/12/23.
//  Copyright © 2016年 BH. All rights reserved.
//

#import "WorkCell.h"

@implementation WorkCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *workCellID = @"workCellID";
    WorkCell * workCell = [tableView dequeueReusableCellWithIdentifier:workCellID];
    if (!workCell) {
        
        workCell = [[WorkCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:workCellID];
    }
    workCell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return workCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.iconImg = [[UIImageView alloc]init];
        [self.contentView addSubview:self.iconImg];
        
        [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.leading.equalTo(self.contentView).with.offset(15);
            make.centerY.equalTo(self.contentView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        //title
        self.titleLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.titleLabel];
        self.titleLabel.font = BHFont(15);
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        self.titleLabel.textColor = BHColor(51, 51, 51);
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.iconImg.mas_trailing).with.offset(15);
            make.centerY.equalTo(self.contentView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(100, 30));
        }];
        
        self.arrowImg = [[UIImageView alloc]init];
        [self.contentView addSubview:self.arrowImg];
        self.arrowImg.image = [UIImage imageNamed:@"ico_work_order_next"];
        
        [self.arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self.contentView).with.offset(-15);
            make.centerY.equalTo(self.contentView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(8, 14));
        }];
        
        self.messageCountLab = [[UILabel alloc]init];
        [self.contentView addSubview:self.messageCountLab];
        self.messageCountLab.textColor = [UIColor grayColor];
        self.messageCountLab.textAlignment = NSTextAlignmentRight;
        self.messageCountLab.font = BHFont(13);
    
        [self.messageCountLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self.arrowImg.mas_trailing).with.offset(-20);
            make.centerY.equalTo(self.contentView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];

        
        //subTitle
        self.subTitle = [[UILabel alloc]init];
        [self.contentView addSubview:self.subTitle];
        self.subTitle.textColor = BHColor(153, 153, 153);
        self.subTitle.textAlignment = NSTextAlignmentRight;
        self.subTitle.font = BHFont(13);
        
        
        [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self.messageCountLab.mas_trailing).with.offset(-35);
              make.centerY.equalTo(self.contentView).with.offset(0);
              make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];
       
    }
    
    return self;
}
@end
